<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>call&apply&bind</title>
</head>
<body>
<script>
//    Object.defineProperty()
//    Array.prototype.slice.call()
//    Function.call
//    console.dir(Function)
//Function.__proto__   ===> call apply bind

//    myCall myApply
/*Function.__proto__.myCall = function () {
    console.log("myCall")
};*/
//console.log(Function.__proto__ === Function.prototype);
//Function.prototype.myCall = function () {
//    console.log("myCall")
//};

let stu1 = {
    name: "stu1",
    age: 100,
    say: function () {
        console.log(this.name + "<---------->" + this.age)
    }
};
let stu2 = {
    name: "stu2",
    age: 10
};



Function.prototype.myCall = function (obj, arr) {};
Function.prototype.myApply = function (obj, arr) {
    if(!(arr instanceof Array)){//false    ===> !"" ===> true
        throw new Error("123456"+"CreateListFromArrayLike called on non-object")
    }
    console.log(this);
    Function.prototype.call(obj,...arr);
//    this.call(obj,...arr);
};
let a = stu1.say.myApply(stu2, [1]);
//let a = stu1.say.apply(stu2, [1,2,3]);
console.log("a=>",a)


//console.dir(Function);
//Array.prototype.slice.apply();
</script>
</body>
</html>